package l1j.server.server.clientpackets;

import java.util.logging.Level;
import java.util.logging.Logger;

import l1j.opqlo.List.OnlineUser;
import l1j.server.echo.ClientThread;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.templates.L1Account;

public class C_ReturnToLogin extends ClientBasePacket {

	/**玩家離線相關*/
	private static Logger _log = Logger.getLogger(C_ReturnToLogin.class.getName());

	@Override
	public String getType() {
		return "[C] C_ReturnToLogin";
	}

	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);
			final L1PcInstance pc = client.getActiveChar();
			if (pc != null) {
				client.quitGame();
			}

			final L1Account account = client.getAccount();
			if (account != null) {
				OnlineUser.get().remove(account.get_login());
			}

		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}

}
